package ngames.com.sushitv;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;
import android.view.View;
import android.view.WindowManager;


import ngames.com.sushitv.core.AppModel;
import ngames.com.sushitv.core.AppModelImpl;
import ngames.com.sushitv.entity.AnimeIntro;
import ngames.com.sushitv.entity.SearchPrompt;
import ngames.com.sushitv.entity.SearchRequestAll;
import ngames.com.sushitv.entity.VideoDetails;
import ngames.com.sushitv.interfaces.ChangFragment;
import ngames.com.sushitv.tools.FBHelp;
import ngames.com.sushitv.tools.PreferenceManager;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import java.util.List;

/**
 * Created by lcc on 2016/1/7.
 */
public class AppApplication extends Application {
    public RequestQueue queue = null;
    public ImageLoader imageLoader = null;
    public static String myIMEI;
    public static String tempStr;
    public String token = "601ba054bf0c5a41";
    private static Context context;
    private AppModel mAppModel;
    private static int searchView;//获取view的位置
    private static SearchPrompt searchPrompt;
    private static ChangFragment changFragment;
    private static String searchKeyWord;
    private static SearchRequestAll searchRequestAll;
    private static View searchFragmentView;
    private static String searchRequestType;//查找类型
    private static String mVsId;//用来保存vs_id
    private static VideoDetails mVideoDetails;//保存信息
    private static AnimeIntro mAnimeIntro;//保存番剧详情
    /**
     * 屏幕高宽
     */
    public static int screenHeight = 0;
    public static int screenWidth = 0;




    @Override
    public void onCreate() {
        MultiDex.install(this);
        super.onCreate();
        mAppModel = new AppModelImpl(this);
        WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        screenHeight = wm.getDefaultDisplay().getHeight();
        screenWidth = wm.getDefaultDisplay().getWidth();
        FBHelp.init(this);
        PreferenceManager.init(this);

        //创建默认的ImageLoader配置参数
        ImageLoaderConfiguration configuration = ImageLoaderConfiguration
                .createDefault(this);
        //Initialize ImageLoader with configuration.
        com.nostra13.universalimageloader.core.ImageLoader.getInstance().init(configuration);
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    public AppModel getAppModel() {
        if (mAppModel == null) {
            mAppModel = new AppModelImpl(this);
        }
        return mAppModel;
    }

    public static AppModel getAppModel(Activity activity) {
        AppApplication application = (AppApplication) activity.getApplication();
        AppModel appModel = application.getAppModel();
        return appModel;
    }

    public static String getMyIMEI() {
        return myIMEI;
    }

    public static void setMyIMEI(String myIMEI) {
        AppApplication.myIMEI = myIMEI;
    }

    public static String getTempStr() {
        return tempStr;
    }

    public static void setTempStr(String tempStr) {
        AppApplication.tempStr = tempStr;
    }

    public static Context getContext() {
        return context;
    }

    public static void setContext(Context context) {
        AppApplication.context = context;
    }

    public static int getSearchView() {
        return searchView;
    }

    public static void setSearchView(int searchView) {
        AppApplication.searchView = searchView;
    }

    public static SearchPrompt getSearchPrompt() {
        return searchPrompt;
    }

    public static void setSearchPrompt(SearchPrompt searchPrompt) {
        AppApplication.searchPrompt = searchPrompt;
    }

    public static ChangFragment getChangFragment() {
        return changFragment;
    }

    public static void setChangFragment(ChangFragment changFragment) {
        AppApplication.changFragment = changFragment;
    }

    public static String getSearchKeyWord() {
        return searchKeyWord;
    }

    public static void setSearchKeyWord(String searchKeyWord) {
        AppApplication.searchKeyWord = searchKeyWord;
    }

    public static SearchRequestAll getSearchRequestAll() {
        return searchRequestAll;
    }

    public static void setSearchRequestAll(SearchRequestAll searchRequestAll) {
        AppApplication.searchRequestAll = searchRequestAll;
    }
    public static void setSearchFragmentView(View searchFragmentView) {
        AppApplication.searchFragmentView = searchFragmentView;
    }
    public static View getSearchFragmentView(){
        return searchFragmentView;
    }

    public static String getSearchRequestType() {
        return searchRequestType;
    }

    public static void setSearchRequestType(String searchRequestType) {
        AppApplication.searchRequestType = searchRequestType;
    }

    public static String getmVsId() {
        return mVsId;
    }

    public static void setmVsId(String mVsId) {
        AppApplication.mVsId = mVsId;
    }

    public static VideoDetails getmVideoDetails() {
        return mVideoDetails;
    }

    public static void setmVideoDetails(VideoDetails mVideoDetails) {
        AppApplication.mVideoDetails = mVideoDetails;
    }

    public static AnimeIntro getmAnimeIntro() {
        return mAnimeIntro;
    }

    public static void setmAnimeIntro(AnimeIntro mAnimeIntro) {
        AppApplication.mAnimeIntro = mAnimeIntro;
    }
}
